cc.Class({
    extends: cc.Component,

    properties: {
        queryTab:'paiming',
        query:{
            default:null,
            type:cc.Node
        },
        contain:{
            default:null,
            type:cc.Node
        },
        playTab:'shuangkou',
        play:{
            default:null,
            type:cc.Node
        },
        queryRecord:{
            default:null,
            type:cc.Prefab
          }
    },

    onLoad: function () {
        this.initTab(this.query.children,this.queryTab);
        this.initContain(this.contain.children,this.queryTab);
        this.initTab(this.play.children,this.playTab);
    },
    initTab:function(tabs,activeTab){
        tabs.map(function(item){
            if(activeTab==item.name){
                item.getChildByName('back').active=true;
            }else{
                item.getChildByName('back').active=false;
            }
        })
    },
    initContain:function(tabs,activeTab){
        tabs.map(function(item){
            if(activeTab==item.name){
                item.active=true;
            }else{
                item.active=false;
            }
        })
    },
    queryTabClick:function(e){
        if(this.queryTab!=e.currentTarget.name){
           this.queryTab=e.currentTarget.name;
           this.initTab(this.query.children,this.queryTab);
           this.initContain(this.contain.children,this.queryTab)
        }
    },
    playTabClick:function(e){
        if(this.playTab!=e.currentTarget.name){
           this.playTab=e.currentTarget.name;
           this.initTab(this.play.children,this.playTab);
        }
    },
    onQueryRecordClick:function(){
        cc.beimi.openwin4 = cc.instantiate(this.queryRecord) ;
        cc.beimi.openwin4.parent = cc.find('Canvas');
    },
});
